package com.daka.vo.response;

import com.daka.entity.Project;
import com.daka.entity.Team;
import lombok.Data;
import lombok.ToString;
import org.apache.ibatis.type.Alias;

import java.math.BigDecimal;
import java.util.Date;

@Data
@ToString
@Alias(value = "team")
public class TeamDetail {
    /**
     * .
     */
    private Long id;

    /**
     * .
     */
    private String code;

    /**
     * .名称
     */
    private String name;

    /**
     * .
     */
    private Long area;

    /**
     * .大区名称
     */
    private String areaName;

    /**
     * .状态1正常，
     */
    private Integer status;

    /**
     * .团队照片
     */
    private String teamPic;

    /**
     * .队长(user表id）
     */
    private Long leader;

    /**
     * .队长姓名
     */
    private String leaderName;

    /**
     * .队长图片
     */
    private String leaderPic;

    /**
     * .总金额
     */
    private BigDecimal totalMoney;

    private Long projectId;

    private String projectName;

    private String projectInfo;

    private BigDecimal projectMoney;

    /**
     * .创建时间
     */
    private Date createTime;

    /**
     * .
     */
    private Date updateTime;

    /**
     * .
     */
    private String updateUser;

    /**
     *  项目捐款人次.
     */
    private Integer peopleCount;

    //捐款人次
    private int amount;


    public static TeamDetail build(Team team,Project project,Integer peopleCount,String leaderName){
        TeamDetail teamDetail = new TeamDetail();
        teamDetail.setArea(team.getArea());
        teamDetail.setAreaName(team.getAreaName());
        teamDetail.setCode(team.getCode());
        teamDetail.setCreateTime(team.getCreateTime());
        teamDetail.setId(team.getId());
        teamDetail.setLeader(team.getLeader());
        teamDetail.setLeaderPic(team.getLeaderPic());
        teamDetail.setName(team.getName());
        teamDetail.setProjectId(project.getId());
        teamDetail.setProjectInfo(project.getInfo());
        teamDetail.setProjectMoney(project.getMoney().divide(BigDecimal.valueOf(100)));
        teamDetail.setProjectName(project.getName());
        teamDetail.setStatus(team.getStatus());
        teamDetail.setTeamPic(team.getTeamPic());
        teamDetail.setTotalMoney(team.getTotalMoney().divide(BigDecimal.valueOf(100)));
        teamDetail.setUpdateTime(team.getUpdateTime());
        teamDetail.setUpdateUser(team.getUpdateUser());
        teamDetail.setPeopleCount(peopleCount);
        teamDetail.setLeaderName(leaderName);
        return teamDetail;
    }
}